package 力扣日常刷题.木22一月.第02天0109;

/**
 * @author 帅小伙
 * @date 2022/1/9
 * @description
 * https://leetcode-cn.com/problems/slowest-key/
 * 就是单个持续时间  不需要差分
 */
public class Demo01按键最长的时间{

    public char slowestKey(int[] releaseTimes, String keysPressed) {
        int n = releaseTimes.length;
        char ans = keysPressed.charAt(0);
        int maxTime = releaseTimes[0];
        for (int i = 1; i < n; i++) {
            char key = keysPressed.charAt(i);
            int time = releaseTimes[i] - releaseTimes[i - 1];
            if (time > maxTime || (time == maxTime && key > ans)) {
                ans = key;
                maxTime = time;
            }
        }
        return ans;


    }
}
